package com.mutouren.modules.datapush;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringContextHelper {
	
	private static ClassPathXmlApplicationContext springContext;
	
	public static Object getBean(String beanName) {
		return springContext.getBean(beanName);
	}
	
	public static void loadSpringConfig() {
		springContext = new ClassPathXmlApplicationContext("spring-context.xml");	
		
		System.out.println("bean count : " + springContext.getBeanDefinitionCount());
		for(String beanName : springContext.getBeanDefinitionNames()) {
			System.out.println(beanName);
		}				
	}
	
	public static void close() {
		springContext = null;
		if (springContext != null) {
			springContext.close();
		}
	}	
}
